﻿Imports System
Imports System.Collections.Generic
Imports System.Text
Imports System.Data
Imports System.Data.OleDb
Imports System.Windows.Forms
Imports System.Collections
Imports _1065081_1065104.SPDTO
Imports _1065081_1065104.SPDAO
Imports _1065081_1065104.Global_Class
Imports System.Data.SqlClient
Namespace SPBUS
    Public Class cbusisanpham
        Private _cusData As New CSanPhamDAO 
        Public Sub Insert(ByVal _sanpham As CsanphamDTO)
            Dim bState As Boolean = _cusData.AddNewsanpham(_sanpham)
            If bState = True Then
                MessageBox.Show("Đã thêm mới căn hộ mã số " & _sanpham.mach, "Thong bao", MessageBoxButtons.OK, MessageBoxIcon.Information)
            Else
                MessageBox.Show("Không thể thêm mới căn hộ mã số " & _sanpham.mach, "Thong bao", MessageBoxButtons.OK, MessageBoxIcon.Information)
            End If
        End Sub
        Public Sub Delete(ByVal _cusID As String)
            Dim bState As Boolean = _cusData.Deletesanpham(_cusID.Trim())
            If bState = True Then
                MessageBox.Show("Đã xóa căn hộ mã số " & _cusID, "Thong bao", MessageBoxButtons.OK, MessageBoxIcon.Information)
            Else
                MessageBox.Show("Không thể xóa căn hộ mã số " & _cusID, "Thong bao", MessageBoxButtons.OK, MessageBoxIcon.Information)
            End If
        End Sub
        Public Sub Update(ByVal _sanpham As CsanphamDTO)
            Dim bState As Boolean = _cusData.Updatesanpham(_sanpham)
            If bState = True Then
                MessageBox.Show("Đã cập nhật căn hộ mã số " & _sanpham.mach, "Thong bao", MessageBoxButtons.OK, MessageBoxIcon.Information)
            Else
                MessageBox.Show("Không thể cập nhật căn hộ mã số " & _sanpham.mach, "Thong bao", MessageBoxButtons.OK, MessageBoxIcon.Information)
            End If
        End Sub
        Public Function Search(ByVal _idCode As String, ByVal _cusName As String, ByVal _cusIdentity As String, ByVal _cusTel As String) As DataTable
            Return _cusData.Searchsanpham(_idCode, _cusName, _cusIdentity, _cusTel)
        End Function
        Public Function GetsanphamID(ByVal strID As String, ByVal field As String, ByVal table As String, ByVal length As Integer) As String
            Return _cusData.GetsanphamID(strID, field, table, length)
        End Function
    End Class
End Namespace

